
#ifndef _I7816_HAL_H_
#define _I7816_HAL_H_

#include "i7816_define.h"

/*======================================接口===============================================*/

// void i7816_hal_connect_init(i7816_hw_t* hw);

i7816_status_t i7816_hal_select(i7816_hw_t* hw);

void i7816_hal_deactive(i7816_hw_t* hw);

i7816_status_t i7816_hal_activate(i7816_hw_t* hw, i7816_class_t type);

i7816_status_t i7816_hal_reset(i7816_hw_t* hw, i7816_class_t type, reset_mode_t mode);

uint8_t i7816_hal_get_support_type(i7816_hw_t* hw);

bool i7816_hal_check_present(i7816_hw_t* hw);

/*======================================时间===============================================*/

void i7816_hal_timer_init(uint32_t freq);

uint32_t i7816_hal_get_clk_count(void);

void i7816_hal_delay(uint32_t clk);

void i7816_hal_delay_etu(uint32_t etu, uint8_t FiDi);

void i7816_hal_delay_ms(uint32_t ms);

/*======================================配置===============================================*/

void i7816_hal_config(i7816_hw_t* hw,  i7816_hw_param_t* param);

void i7816_hal_init(i7816_hw_t* hw, uint32_t freq);

/*======================================收发===============================================*/
i7816_status_t i7816_hal_receive(i7816_hw_t* hw, uint16_t* rdata, uint32_t wait_clk);

i7816_status_t i7816_hal_send(i7816_hw_t* hw, uint8_t byte);

void i7816_hal_usart_init(i7816_hw_t* hw);

void i7816_hal_delay_guard_time(i7816_hw_t* hw, uint32_t gt_clk);

// void i7816_hal_flush(i7816_hw_t* hw);
void i7816_hal_flush(i7816_hw_t* hw, transfer_dir_t dir);

void i7816_hal_setup(i7816_hw_t* hw, transfer_dir_t dir);

#endif	//_I7816_HAL_H_

